<?php

/**
 * 合同类别仓库
 * @author wangwx 2015-5-12
 */
namespace common\repositories\myhtsq;
use common\repositories\BaseRepository;
use common\support\StringHelper;
use common\entities\myhtsq\ContractCategoryEntity;
class ContractCategoryRepository extends BaseRepository{

	
	/**
	 * 构造方法
	 * @param unknown $config (optional)
	 */
	public function __construct($config = [])
	{
		parent::__construct($config);
	}
	
	/**
	 * 获取所有合同类别.
	 * @return array
	 */
	public static function getAllContractCategory() {
		return ContractCategoryEntity::find()->all();
	}
	
	/**
	 * 根据合同类别id,获取合同类别名称
	 * @param string $categoryId 合同类别id
	 * @return string 合同类别名称
	 */
	public static function getCategoryNameByCategoryId($categoryId){
		return ContractCategoryEntity::find()->select('category_name')->where(['category_id'=>$categoryId])->scalar();
	}

    /**
     * 根据合同类别id,获取合同类别名称
     * @param string $categoryIds 合同类别id
     * @return array
     */
    public static function getAllCategoryNameByCategoryIds($categoryIds){
        return ContractCategoryEntity::find()
            ->select('category_name,category_id')
            ->where(['category_id' => $categoryIds])
            ->asArray()
            ->all();
    }
	
	
	
}